#ifndef _RTC_H_
#define _RTC_H_

#include "common_def.h"

/*
 * A simple representation of date time.
 * For 2012 April 2, year=2012, month=4, date=2.
 * Time is in 24 hour format. 13:23:00, then hour=13, minute=23, second=00.
 */
struct DATE_TIME_T
{
    uint16 year;    // 2012
    uint8 month;    // 4
    uint8 date;     // 2
    uint8 weekday;  // 1 - 7. 7 for Sunday.
    uint8 hour;     // 13
    uint8 minute;   // 23
    uint8 second;   // 00
};

typedef struct DATE_TIME_T DATE_TIME_T;

void rtc_set_time(const struct DATE_TIME_T* time);
void rtc_get_time(struct DATE_TIME_T* time);
bool time_is_valid(const struct DATE_TIME_T* time);
// time difference in seconds
uint32 time_diff(struct DATE_TIME_T* old_time, struct DATE_TIME_T* new_time);


#endif
